package com.example.animationmodule

import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.animation.*
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity

class TweenActivityXml : AppCompatActivity() {
    private  val TAG = "TweenActivity"
    private lateinit var imageView: ImageView
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_tween)
        this.imageView=findViewById(R.id.iv_animation)
    }

    fun startTranslation(view: View) {
        Log.d(TAG, "startTranslation: ")
        val loadAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_translate)
        loadAnimation.duration=2000
        loadAnimation.repeatCount=Animation.INFINITE
        loadAnimation.repeatMode=Animation.REVERSE
        this.imageView.startAnimation(loadAnimation)

    }

    fun startScale(view: View) {
//        val scaleAnimation = ScaleAnimation(0f, 0.5f, 0f, 1f)
//        scaleAnimation.duration=2000
        val loadAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_anim)
        loadAnimation.duration=2000
        this.imageView.startAnimation(loadAnimation)
    }
    fun startRotate(view: View) {
//        val rotateAnimation = RotateAnimation(0f, 360f)
//        rotateAnimation.duration=2000
        val loadAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate_anim)
        loadAnimation.duration=2000
        this.imageView.startAnimation(loadAnimation)
    }
    fun startAlpha(view: View) {
//        val alphaAnimation = AlphaAnimation(0.toFloat(), 1.toFloat())
//        alphaAnimation.duration=2000
        val loadAnimation = AnimationUtils.loadAnimation(this, R.anim.alpha_anim)
        loadAnimation.duration=2000
        this.imageView.startAnimation(loadAnimation)
    }
}
